#include <bits/stdc++.h>
using namespace std;
int ans;
int n, ju, ssu, ju2,m, l, v, d[100005], vv[100005], a[100005], p[100005];
bool g[100005];
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++)
    {
        cin >> n >> m >> l >> v;
        for(int j = 1; j <= n; j++)
            cin >> d[j] >> vv[j] >> a[j];

        for(int j = 1; j <= m; j++)
        {
            cin >> p[j];
            g[p[j]] = 1;
        }
        for(int j = 1; j <= n; j++)
        {
            for(int k = d[j]; k <= n; k++)
            {
                if(g[k] == 1)
                {
                    ju = k - d[j];
                    break;
                }
            }
            ju2 = l - d[j];
            if(a[j] < 0)
            {
                ssu = sqrt(vv[j] * vv[j] + 2.0 * a[j] * ju);
                if(ssu > v)
                {
                    ans++;
                }
            }
            else
            {
                if(vv[j] * vv[j] + 2 * a[j] * ju2 > v * v)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << " ";
    cout << ans << "\n";
    return 0;
}
